const jwt = require('jsonwebtoken')
const secret = "zhangmo-01-09-03"

const JWT = {
    createToken: (data, time) => {
        let token = jwt.sign(data, secret, { expiresIn: time })

        return token
    },
    verifyToken: (token) => {
        try {
            return jwt.verify(token, secret)
        } catch (error) {
            console.log("错误码", error)
            return false
        }
    }
}

module.exports = JWT